package com.yanqu.road.server.manager.activity.hsisland.handler.impl;

import com.yanqu.road.entity.activity.hsisland.HsIslandExploreResult;
import com.yanqu.road.entity.activity.hsisland.config.HsIslandConfig;
import com.yanqu.road.entity.activity.hsisland.config.HsIslandRelicConfig;
import com.yanqu.road.entity.activity.hsisland.data.HsIslandEventData;
import com.yanqu.road.entity.activity.hsisland.data.HsIslandReceiveRelicRewardData;
import com.yanqu.road.entity.activity.hsisland.enums.HsIslandYnFlagEnum;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandActivity;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandIsland;
import com.yanqu.road.server.manager.activity.hsisland.handler.param.HsIslandExploreHandlerReq;
import com.yanqu.road.server.manager.activity.hsisland.handler.param.HsIslandExploreHandlerResp;
import com.yanqu.road.server.manager.activity.hsisland.handler.HsIslandIEventHandler;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

public class HsIslandEventRelicHandler implements HsIslandIEventHandler {

    /**
     * 探索后处理
     * @param req
     * @return
     */
    @Override
    public HsIslandExploreResult explore(HsIslandExploreHandlerReq req) {
        HsIslandEventData eventData = req.getEventData();
        CrossHsIslandIsland island = req.getIsland();
        HsIslandConfig config = island.getConfig();
        //事件注入坐标
        eventData.addPosition(req.getX(), req.getY());
        //岛屿注入事件
        island.putEvent(eventData);
        //随机出3个宝箱的奖励
        for (HsIslandRelicConfig relicConfig : config.getRelicConfigMap().values()) {
            Property reward = PropertyHelper.parseNewStringToProperty(relicConfig.getReward());
            HsIslandReceiveRelicRewardData relicRewardData = new HsIslandReceiveRelicRewardData();
            relicRewardData.setRelicConfigId(relicConfig.getId());
            relicRewardData.setReward(PropertyHelper.parsePropertyToString(reward));
            relicRewardData.setIndex(-1);//-1表示未领取
            relicRewardData.setReceiveFlag(HsIslandYnFlagEnum.NOT.getType());
            eventData.putReceiveRelicReward(relicRewardData);
        }
        //返回
        HsIslandExploreResult resp = new HsIslandExploreResult();
        resp.addEventData(eventData);
        return resp;
    }
}
